/**
 * @description 测试页
 */

import Flip from './packages';

const list = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple'];

const div = document.createElement('div');

div.innerHTML = list.map((rgb) => `<div style="background-color:${rgb};">${rgb}</div>`).join('');

document.body.appendChild(div);

const flip = new Flip(div, 1000);

function play() {
  flip.first();

  const { children } = div;
  const newnode = children[children.length - 1];
  div.insertBefore(newnode, children[0]);

  flip.play({ complete: play });
}

play();
